<!DOCTYPE html>
<!--头部公共部分-->
{include file="common/header" /}

<div class="x-nav">
      <span class="layui-breadcrumb">
        <a>首页</a>
        <a>财务</a>
        <a>
          <cite>财务汇总</cite></a>
      </span>
    <a class="layui-btn layui-btn-xs layui-btn-small" style="float:right;margin-top: 10px;"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh"></i> </a>
</div>
<div class="layui-tab layui-tab-card" lay-filter="filter">
    <ul class="layui-tab-title">
        <li class="layui-this">统计明细报表</li>
        <li>校区业绩明细报表</li>
        <li>个人业绩明细报表</li>
        <li>退费明细报表</li>
    </ul>
    <div class="layui-tab-content" >
        <div class="layui-tab-item layui-show">
            <div id="container_one" style="height: 550px;"></div>
            <div style="position: absolute; top: 120px; width: auto; height: 100px;">
                <div class="layui-form-item">
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="width: auto;  color:#01AAED;font-weight: bold; font-size: 14px;">应收款项总额(订单金额):</label>
                        <label class="layui-form-label" style="width: auto;  color:#01AAED; font-weight: bold; font-size: 14px;">{$total_amount} 元</label>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline" style="margin-top: -20px;" >
                        <label class="layui-form-label" style="width: auto;  color:#ef4136;font-weight: bold; font-size: 14px;">实收款项总额(收款金额):</label>
                        <label class="layui-form-label" style="width: auto; color:#ef4136; font-weight: bold; font-size: 14px;">{$amount} 元</label>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline" style="margin-top: -20px;" >
                        <label class="layui-form-label" style="width: auto;  color:#000000;font-weight: bold; font-size: 14px;">净收款项总额(课消金额):</label>
                        <label class="layui-form-label" style="width: auto; color:#000000; font-weight: bold; font-size: 14px;">{$net_income} 元</label>
                    </div>
                </div>
            </div>
            <div  class="x-body" class="clear:both;">
                <div class="layui-row" style="border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;">
                    <div class="layui-form layui-col-md12 x-so layui-form-pane">
                        <div class="layui-input-inline">
                            <select name="payment_method_one" lay-search="" lay-verify="required">
                                <option selected value=""></option>
                                {foreach name="data[20]" id="vo"}
                                <option value="{$vo.name}">{$vo.name}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" style="width: auto;" placeholder="选择日期范围" name="payment_method_date" id="start">
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" id="search_one">
                                <i class="layui-icon layui-icon-search"></i>筛选</button>
                            <button class="layui-btn layui-btn-danger" id="clear_one">
                                <i class="layui-icon"></i>重置</button>

                        </div>
                    </div>
                </div>
                <table class="layui-hide" id="LAY_table_user_one" lay-filter="Event"></table>
            </div>
            <script>
                    var dom = document.getElementById("container_one");
                    var myChart = echarts.init(dom);
                    option = null;
                    var dictionary = eval('{$jsondata}');
                    var data_ =[];
                    for(var i=0; i < dictionary.length; i++){
                    var row = {};
                    row['value'] = dictionary[i].value;
                    row['name'] = dictionary[i].name;
                    data_[i] = row;
                    }
                    option = {
                    backgroundColor: '#ffffff',

                    title: {
                    //    text: '财务统计报表',
                    left: 'center',
                    top: 20,
                    textStyle: {
                    color: '#000'
                    }
                    },

                    tooltip : {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },


                    /*
                    visualMap: {
                    show: false,
                    min: 50,
                    max: 600,
                    inRange: {
                    colorLightness: [0, 1]
                    }
                    },
                    */


                    series : [
                    {
                    name:'客户分析报表',
                    type:'pie',
                    radius : '55%',
                    center: ['50%', '50%'],


                        /*
                    data:[

                    {value:335, name:'未分配'},
                    {value:310, name:'未处理'},
                    {value:274, name:'已联系'},
                    {value:235, name:'已邀约'},
                    {value:220, name:'已上门'},
                    {value:220, name:'已交定金'},
                    {value:260, name:'已成交'},

                    ].sort(function (a, b) { return a.value - b.value; }),
                    */
                    data:data_.sort(function (a, b) { return a.value - b.value; }),

                    roseType: 'radius',
                    label: {
                    normal: {
                    textStyle: {
                    //         color: 'rgba(0, 191, 255, 1)',
                    fontSize: 16
                    }
                    }
                    },

                    labelLine: {
                    normal: {
                    /*
                    lineStyle: {
                    color: 'rgba(0, 191, 255, 1)'
                    },
                    */
                    smooth: 0.2,
                    length: 10,
                    length2: 20
                    }
                    },



                    itemStyle: {
                    normal: {
                    //                 color: '#c23531',
                    shadowBlur: 200,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                    },

                    animationType: 'scale',
                    animationEasing: 'elasticOut',
                    animationDelay: function (idx) {
                    return Math.random() * 200;
                    }
                    }
                    ]
                    };
                    if (option && typeof option === "object") {
                    myChart.setOption(option, true);
                    }
            </script>
        </div>

        <div class="layui-tab-item">
            <div id="container_two" style="height: 550px;"></div>
            <div style="position: absolute; top: 120px; width: auto; height: 100px;">
                <div class="layui-form-item">
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="width: auto;  color:#01AAED;font-weight: bold; font-size: 14px;">校区总业绩:</label>
                        <label class="layui-form-label label_two"  style="width: auto;  color:#01AAED; font-weight: bold; font-size: 14px;">{$campus_money_sum} 元</label>
                    </div>
                </div>
            </div>
            <div  class="x-body" class="clear:both;">
                <div class="layui-row" style="border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;">
                    <div class="layui-form layui-col-md12 x-so layui-form-pane">
                        <div class="layui-input-inline">
                            <select name="campus_name" lay-search="" lay-verify="required">
                                <option selected value=""></option>
                                {foreach name="campus_name" id="vo"}
                                <option value="{$vo.campus_name}">{$vo.campus_name}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" style="width: 180px;" name="date_range"  id="range_date" placeholder="选择日期范围" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" id="search_two">
                                <i class="layui-icon layui-icon-search"></i>筛选</button>
                            <button class="layui-btn layui-btn-danger" id="clear_two">
                                <i class="layui-icon"></i>重置</button>

                        </div>
                    </div>
                </div>
                <table class="layui-hide" id="LAY_table_user_two" lay-filter="Event"></table>
            </div>
        </div>

        <div class="layui-tab-item">
            <div id="container_three" style="height: 550px;"></div>
            <div style="position: absolute; top: 120px; width: auto; height: 100px;">
                <div class="layui-form-item">
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="width: auto;  color:#01AAED;font-weight: bold; font-size: 14px;">个人总业绩:</label>
                        <label class="layui-form-label label_three" style="width: auto;  color:#01AAED; font-weight: bold; font-size: 14px;">{$only_money_sum} 元</label>
                    </div>
                </div>
            </div>
            <div  class="x-body" class="clear:both;">
                <div class="layui-row" style="border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;">
                    <div class="layui-form layui-col-md12 x-so layui-form-pane">
                        <div class="layui-input-inline">
                            <select name="adjustment_name" lay-search="" lay-verify="required">
                                <option selected value=""></option>
                                {foreach name="user" id="vo"}
                                <option value="{$vo.name}">{$vo.name}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" style="width: 180px;" name="date_range_three"  id="range_date_three" placeholder="选择日期范围" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" id="search_three">
                                <i class="layui-icon layui-icon-search"></i>筛选</button>
                            <button class="layui-btn layui-btn-danger" id="clear_three">
                                <i class="layui-icon"></i>重置</button>

                        </div>
                    </div>
                </div>
                <table class="layui-hide" id="LAY_table_user_three" lay-filter="Event"></table>
            </div>
        </div>

        <div class="layui-tab-item">
            <div id="container_four" style="height: 550px;"></div>
            <div style="position: absolute; top: 100px; width: auto; height: 100px;">
                <div class="layui-form-item">
                    <div class="layui-inline" >
                        <label class="layui-form-label" style="width: auto;  color:#ef4136;font-weight: bold; font-size: 14px;">退费总额:</label>
                        <label class="layui-form-label label_four" style="width: auto;  color:#ef4136; font-weight: bold; font-size: 14px;">{$campus_refund_money_sum} 元</label>
                    </div>
                </div>
            </div>
            <div  class="x-body" class="clear:both;">
                <div class="layui-row" style="border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;">
                    <div class="layui-form layui-col-md12 x-so layui-form-pane">
                        <div class="layui-input-inline">
                            <select name="campus_name_refund" lay-search="" lay-verify="required">
                                <option selected value=""></option>
                                {foreach name="campus_name" id="vo"}
                                <option value="{$vo.campus_name}">{$vo.campus_name}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" style="width: 180px;" name="date_range_four"  id="range_date_four" placeholder="选择日期范围" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" id="search_four">
                                <i class="layui-icon layui-icon-search"></i>筛选</button>
                            <button class="layui-btn layui-btn-danger" id="clear_four">
                                <i class="layui-icon"></i>重置</button>

                        </div>
                    </div>
                </div>
                <table class="layui-hide" id="LAY_table_user_four" lay-filter="Event"></table>
            </div>
        </div>
    </div>
</div>
<!--底部公共部分-->
{include file="common/footer" /}

<script>
    layui.use(['form', 'element', 'table','laydate', 'layer', 'laytpl'], function () {
        var $ = layui.$,
            form = layui.form,
            table = layui.table,
            laydate = layui.laydate,
            element = layui.element,
            layer = layui.layer;

        var loading = layer.load();


        element.on('tab(filter)', function(data){
            console.log(this); //当前Tab标题所在的原始DOM元素
            console.log(data.index); //得到当前Tab的所在下标
            console.log(data.elem); //得到当前的Tab大容器


            if(data.index === 0){
                var dom = document.getElementById("container_one");
                var myChart = echarts.init(dom);
                option = null;
                var dictionary = eval('{$jsondata}');
                var data_ =[];
                for(var i=0; i < dictionary.length; i++){
                    var row = {};
                    row['value'] = dictionary[i].value;
                    row['name'] = dictionary[i].name;
                    data_[i] = row;
                }


                option = {
                    backgroundColor: '#ffffff',

                    title: {
                        //    text: '财务统计报表',
                        left: 'center',
                        top: 20,
                        textStyle: {
                            color: '#000'
                        }
                    },

                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },


                    /*
                     visualMap: {
                     show: false,
                     min: 50,
                     max: 600,
                     inRange: {
                     colorLightness: [0, 1]
                     }
                     },
                     */


                    series : [
                        {
                            name:'客户分析报表',
                            type:'pie',
                            radius : '55%',
                            center: ['50%', '50%'],


                            /*
                            data:[

                                {value:335, name:'未分配'},
                                {value:310, name:'未处理'},
                                {value:274, name:'已联系'},
                                {value:235, name:'已邀约'},
                                {value:220, name:'已上门'},
                                {value:220, name:'已交定金'},
                                {value:260, name:'已成交'},

                            ].sort(function (a, b) { return a.value - b.value; }),
                               */

                            data:data_.sort(function (a, b) { return a.value - b.value; }),

                            roseType: 'radius',
                            label: {
                                normal: {
                                    textStyle: {
                                        //         color: 'rgba(0, 191, 255, 1)',
                                        fontSize: 16
                                    }
                                }
                            },

                            labelLine: {
                                normal: {
                                    /*
                                     lineStyle: {
                                     color: 'rgba(0, 191, 255, 1)'
                                     },
                                     */
                                    smooth: 0.2,
                                    length: 10,
                                    length2: 20
                                }
                            },



                            itemStyle: {
                                normal: {
                                    //                 color: '#c23531',
                                    shadowBlur: 200,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            },

                            animationType: 'scale',
                            animationEasing: 'elasticOut',
                            animationDelay: function (idx) {
                                return Math.random() * 200;
                            }
                        }
                    ]
                };
                if (option && typeof option === "object") {
                    myChart.setOption(option, true);
                }

            }   //统计报表

            if(data.index === 1){
                var dom_two = document.getElementById("container_two");
                var myChart_two = echarts.init(dom_two);
                var app = {};
                option = null;
                var data_campus = eval('{$data_campus}');
                var campus_data =[];
                var campus_name = [];
                for(var i=0; i < data_campus.length; i++){
                    var row = {};
                    row['value'] = data_campus[i].value;
                    row['name'] = data_campus[i].campus_name;
                    campus_name[i] = data_campus[i].campus_name;
                    campus_data[i] = row;
                }

                option = {
                    title: {
                        //    text: '校区统计报表',
                        left: 'center',
                        top: 20,
                        textStyle: {
                            color: '#000'
                        }
                    },

                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    legend: {
                        type: 'scroll',
                        orient: 'vertical',
                        right: 10,
                        top: 20,
                        bottom: 20,

                        data:campus_name

                     //  selected: {'未分配':true, '未处理':true,'已联系':true,'已邀约':true,'已上门':false,'已交定金':false,'已成交':false}
                    },
                    series : [
                        {
                            name: '校区',
                            type: 'pie',
                            radius : '55%',
                            center: ['50%', '50%'],

                            /*
                            data:  [

                                {value:335, name:'未分配'},
                                {value:310, name:'未处理'},
                                {value:274, name:'已联系'},
                                {value:235, name:'已邀约'},
                                {value:220, name:'已上门'},
                                {value:220, name:'已交定金'},
                                {value:260, name:'已成交'},



                            ].sort(function (a, b) { return a.value - b.value; }),
                            */


                            data:campus_data.sort(function (a, b) { return a.value - b.value; }),

                            roseType: 'radius',
                            label: {
                                normal: {
                                    textStyle: {
                                        //         color: 'rgba(0, 191, 255, 1)',
                                        fontSize: 16
                                    }
                                }
                            },

                            labelLine: {
                                normal: {
                                    /*
                                     lineStyle: {
                                     color: 'rgba(0, 191, 255, 1)'
                                     },
                                     */
                                    smooth: 0.2,
                                    length: 10,
                                    length2: 20
                                }
                            },



                            itemStyle: {
                                normal: {
                                    //                 color: '#c23531',
                                    shadowBlur: 200,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            },

                            animationType: 'scale',
                            animationEasing: 'elasticOut',
                            animationDelay: function (idx) {
                                return Math.random() * 200;
                            }
                        }
                    ]
                };


                if (option && typeof option === "object") {
                    myChart_two.setOption(option, true);
                }


            }  //校区业绩报表

            if(data.index === 2){
                var dom_three = document.getElementById("container_three");
                var myChart_three = echarts.init(dom_three);
                var app = {};
                option = null;
                var data_only = eval('{$data_only}');
                var only_data =[];
                var only_name = [];
                for(var i=0; i < data_only.length; i++){
                    var row = {};
                    row['value'] = data_only[i].value;
                    row['name'] = data_only[i].only_name;
                    only_name[i] = data_only[i].only_name;
                    only_data[i] = row;
                }

                option = {
                    title: {
                        //    text: '个人统计报表',
                        left: 'center',
                        top: 20,
                        textStyle: {
                            color: '#000'
                        }
                    },

                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    legend: {
                        type: 'scroll',
                        orient: 'vertical',
                        right: 10,
                        top: 20,
                        bottom: 20,

                        data:only_name

                        //  selected: {'未分配':true, '未处理':true,'已联系':true,'已邀约':true,'已上门':false,'已交定金':false,'已成交':false}
                    },
                    series : [
                        {
                            name: '分配人',
                            type: 'pie',
                            radius : '55%',
                            center: ['50%', '50%'],

                            /*
                             data:  [

                             {value:335, name:'未分配'},
                             {value:310, name:'未处理'},
                             {value:274, name:'已联系'},
                             {value:235, name:'已邀约'},
                             {value:220, name:'已上门'},
                             {value:220, name:'已交定金'},
                             {value:260, name:'已成交'},



                             ].sort(function (a, b) { return a.value - b.value; }),
                             */


                            data:only_data.sort(function (a, b) { return a.value - b.value; }),

                            roseType: 'radius',
                            label: {
                                normal: {
                                    textStyle: {
                                        //         color: 'rgba(0, 191, 255, 1)',
                                        fontSize: 16
                                    }
                                }
                            },

                            labelLine: {
                                normal: {
                                    /*
                                     lineStyle: {
                                     color: 'rgba(0, 191, 255, 1)'
                                     },
                                     */
                                    smooth: 0.2,
                                    length: 10,
                                    length2: 20
                                }
                            },



                            itemStyle: {
                                normal: {
                                    //                 color: '#c23531',
                                    shadowBlur: 200,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            },

                            animationType: 'scale',
                            animationEasing: 'elasticOut',
                            animationDelay: function (idx) {
                                return Math.random() * 200;
                            }
                        }
                    ]
                };


                if (option && typeof option === "object") {
                    myChart_three.setOption(option, true);
                }
            }  //个人业绩报表

            if(data.index === 3){
                var dom_four = document.getElementById("container_four");
                var myChart_four = echarts.init(dom_four);
                var app = {};
                option = null;


                var data_refund_campus = eval('{$data_refund_campus}');
                var campus_refund_data =[];
                var campus_refund_name = [];
                for(var i=0; i < data_refund_campus.length; i++){
                    var row = {};
                    campus_refund_data[i] = data_refund_campus[i].refund_value;
                    campus_refund_name[i] = data_refund_campus[i].refund_campus_name;
                }


                option = {
                    title: {
                        //    text: '个人统计报表',
                        left: 'center',
                        top: 20,
                        textStyle: {
                            color: '#000'
                        }
                    },
                    color: ['#3398DB'],
                    tooltip : {
                        trigger: 'axis',
                        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                        }
                    },
                    legend: {
                        right: 10,


                        data:['退费金额']

                        //  selected: {'未分配':true, '未处理':true,'已联系':true,'已邀约':true,'已上门':false,'已交定金':false,'已成交':false}
                    },

                    xAxis: {
                        type: 'category',
                        data: campus_refund_name,
                        axisTick: {
                            alignWithLabel: true
                        }
                    },
                    yAxis: {
                        type: 'value'
                    },

                    series : [
                        {
                            name: '退费金额',
                            type: 'bar',
                            barWidth: '40%',
                            radius : '55%',
                            center: ['50%', '50%'],

                            data:campus_refund_data.sort(function (a, b) { return a.value - b.value; }),

                            roseType: 'radius',
                            label: {
                                normal: {
                                    textStyle: {
                                        //         color: 'rgba(0, 191, 255, 1)',
                                        fontSize: 16
                                    }
                                }
                            },

                            labelLine: {
                                normal: {
                                    /*
                                     lineStyle: {
                                     color: 'rgba(0, 191, 255, 1)'
                                     },
                                     */
                                    smooth: 0.2,
                                    length: 10,
                                    length2: 20
                                }
                            },



                            itemStyle: {
                                normal: {
                                    //                 color: '#c23531',
                                    shadowBlur: 200,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            },

                            animationType: 'scale',
                            animationEasing: 'elasticOut',
                            animationDelay: function (idx) {
                                return Math.random() * 200;
                            }
                        }
                    ]
                };


                if (option && typeof option === "object") {
                    myChart_four.setOption(option, true);
                }
            }  //退费报表

        });

        //日期
        laydate.render({
            elem: '#start',
            range: true
            ,trigger: 'click'
        });

        //数据表格 方法级渲染  统计报表
        var tableIns_one = table.render({
            elem: '#LAY_table_user_one'
            , url: '{:url("finance/pay_type")}'
            , method: 'POST'
            , toolbar: 'true' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
            , defaultToolbar: ['print', 'exports'] // 筛选图标
            , loading: true
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code === 1) {
                    res.code = 0;
                } else {
                    res.code = -1;
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data //解析数据列表
                };
            },
            cols: [[
                {field: 'pay_type', title: '支付方式',style:'color:#01AAED;font-weight: bold;', width:616, sort: true, fixed: false,  align: 'center'
                },{field: 'amount_money', title: '实收金额(元)', style:'font-weight: bold;', width: 616, sort: true, fixed: false, align: 'center'
                }
            ]]
            , height: 'full-180'
            , page: true
            , title: '统计表'
            , limits: [10,20,30,40,50,60,70,80,90,100]
            , done: function () {
                layer.close(loading);
            }
        });  //统计报表
        //搜索项
        $('#search_one').click(function () {
            var field = {};

            field.name = $('select[name=payment_method_one]').val();
            var create_date_rang = $('input[name=payment_method_date]').val();
            if(create_date_rang.length > 0){
                strs_date=create_date_rang.split("-"); //字符分割
                field.start_date = strs_date[0]+'-'+strs_date[1]+'-'+strs_date[2];
                field.end_date = strs_date[3]+'-'+strs_date[4]+'-'+strs_date[5];
            }
            console.log(field);
            tableIns_one.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });


        });//清除
        $('#clear_one').click(function () {
            $('.layui-form-pane').find('.layui-input-inline').each(function (index, element) {
                $(element).find('input[type=text]').val('');
                $(element).find('select').val('');
            })
            tableIns_one.reload({
                where: {
                    'payment_method_one': '',
                    'payment_method_date': '',
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });





        //数据表格 方法级渲染  统计报表
        var tableIns_two = table.render({
            elem: '#LAY_table_user_two'
            , url: '{:url("finance/campuslists")}?status=' + true
            , method: 'POST'
            , toolbar: 'true' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
            , defaultToolbar: ['print', 'exports'] // 筛选图标
            , loading: true
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code === 1) {
                    res.code = 0;
                } else {
                    res.code = -1;
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data //解析数据列表
                };
            },
            cols: [[
                {field: 'contract_number', title: '订单编号', style:'color:#01AAED;font-weight: bold;',  width: 200, align: 'center'
                },{field: 'campus_id_all_text', title: '校区', width: 220, align: 'center'
                },{field: 'assignment_all_text', title: '收费归属', width: 100, align: 'center'
                },{field: 'rate_all', title: '比率', width: 100, align: 'center'
                },{field: 'rate_all_money', title: '所分金额(元)',style:'color:#01AAED;font-weight: bold;', width: 200, align: 'center'
                },{field: 'amount_already_all', title: '付款金额(元)',style:'color:#FF5722;font-weight: bold;', width: 200, align: 'center'
                },{field: 'update_time', title: '生成时间', width: 200, align: 'center'
                }
            ]]
            , height: 'full-180'
            , page: true
            , title: '校区业绩分配表'
            , limits: [10,20,30,40,50,60,70,80,90,10000000]
            , done: function () {
                layer.close(loading);
            }
        });  //校区业绩统计报表
        //日期
        laydate.render({
            elem: '#range_date',
            range: true
            ,trigger: 'click'
        });
        //搜索项
        $('#search_two').click(function () {
            var field = {};
            field.campus_id_all_text = $('select[name=campus_name]').val();
            var create_date_rang = $('input[name=date_range]').val();
            if(create_date_rang.length > 0){
                strs_date=create_date_rang.split("-"); //字符分割
                field.start_date = strs_date[0]+'-'+strs_date[1]+'-'+strs_date[2];
                field.end_date = strs_date[3]+'-'+strs_date[4]+'-'+strs_date[5];
            }
            console.log(field);
            tableIns_two.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });

            $.ajax({
                url: '/admin/finance/searchdata?type=' + 2,
                method: "post",
                data: field,
                beforeSend: function () {
                    isLoad = layer.load(0, {
                        shade: false
                    }); //0代表加载的风格，支持0-2
                },
                success: function (result) {
              //      layer.msg(result.msg);
                    if (result.code === 1) {

                        var campus_json_data = eval('(' + result.data + ')');
                        console.log(campus_json_data.campus_json);
                        $('.label_two').text(campus_json_data.campus_sum+' 元');

                        var dom_two = document.getElementById("container_two");
                        var myChart_two = echarts.init(dom_two);
                        var app = {};
                        option = null;
                        var data_campus = campus_json_data.campus_json;
                        var campus_data =[];
                        var campus_name = [];
                        for(var i=0; i < data_campus.length; i++){
                            var row = {};
                            row['value'] = data_campus[i].value;
                            row['name'] = data_campus[i].campus_name;
                            campus_name[i] = data_campus[i].campus_name;
                            campus_data[i] = row;
                        }

                        option = {
                            title: {
                                left: 'center',
                                top: 20,
                                textStyle: {
                                    color: '#000'
                                }
                            },

                            tooltip : {
                                trigger: 'item',
                                formatter: "{a} <br/>{b} : {c} ({d}%)"
                            },
                            legend: {
                                type: 'scroll',
                                orient: 'vertical',
                                right: 10,
                                top: 20,
                                bottom: 20,

                                data:campus_name

                            },
                            series : [
                                {
                                    name: '校区',
                                    type: 'pie',
                                    radius : '55%',
                                    center: ['50%', '50%'],

                                    data:campus_data.sort(function (a, b) { return a.value - b.value; }),

                                    roseType: 'radius',
                                    label: {
                                        normal: {
                                            textStyle: {
                                                fontSize: 16
                                            }
                                        }
                                    },

                                    labelLine: {
                                        normal: {

                                            smooth: 0.2,
                                            length: 10,
                                            length2: 20
                                        }
                                    },



                                    itemStyle: {
                                        normal: {
                                            //                 color: '#c23531',
                                            shadowBlur: 200,
                                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                                        }
                                    },

                                    animationType: 'scale',
                                    animationEasing: 'elasticOut',
                                    animationDelay: function (idx) {
                                        return Math.random() * 200;
                                    }
                                }
                            ]
                        };


                        if (option && typeof option === "object") {
                            myChart_two.setOption(option, true);
                        }



                    }

                },
                complete: function () {
                    layer.close(isLoad)
                },
                error: function (error) {
                    console.log(error)
                }
            });


        });//清除
        $('#clear_two').click(function () {
            $('.layui-form-pane').find('.layui-input-inline').each(function (index, element) {
                $(element).find('input[type=text]').val('');
                $(element).find('select').val('');
            })
            tableIns_two.reload({
                where: {
                    'campus_id_all_text': '',
                    'start_date': '',
                    'end_date': '',
                    'date_range':'',
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            $('.label_two').text('{$campus_money_sum}'+' 元');
            var dom_two = document.getElementById("container_two");
            var myChart_two = echarts.init(dom_two);
            var app = {};
            option = null;
            var data_campus = eval('{$data_campus}');
            var campus_data =[];
            var campus_name = [];
            for(var i=0; i < data_campus.length; i++){
                var row = {};
                row['value'] = data_campus[i].value;
                row['name'] = data_campus[i].campus_name;
                campus_name[i] = data_campus[i].campus_name;
                campus_data[i] = row;
            }

            option = {
                title: {
                    left: 'center',
                    top: 20,
                    textStyle: {
                        color: '#000'
                    }
                },

                tooltip : {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    type: 'scroll',
                    orient: 'vertical',
                    right: 10,
                    top: 20,
                    bottom: 20,
                    data:campus_name
                },
                series : [
                    {
                        name: '校区',
                        type: 'pie',
                        radius : '55%',
                        center: ['50%', '50%'],
                        data:campus_data.sort(function (a, b) { return a.value - b.value; }),

                        roseType: 'radius',
                        label: {
                            normal: {
                                textStyle: {
                                    fontSize: 16
                                }
                            }
                        },

                        labelLine: {
                            normal: {
                                smooth: 0.2,
                                length: 10,
                                length2: 20
                            }
                        },



                        itemStyle: {
                            normal: {
                                shadowBlur: 200,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        },

                        animationType: 'scale',
                        animationEasing: 'elasticOut',
                        animationDelay: function (idx) {
                            return Math.random() * 200;
                        }
                    }
                ]
            };


            if (option && typeof option === "object") {
                myChart_two.setOption(option, true);
            }


        });




        //数据表格 方法级渲染  统计报表
        var tableIns_three = table.render({
            elem: '#LAY_table_user_three'
            , url: '{:url("finance/onlylists")}?status=' + true
            , method: 'POST'
            , toolbar: 'true' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
            , defaultToolbar: ['print', 'exports'] // 筛选图标
            , loading: true
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code === 1) {
                    res.code = 0;
                } else {
                    res.code = -1;
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data //解析数据列表
                };
            },
            cols: [[
                {field: 'contract_number', title: '订单编号', style:'color:#01AAED;font-weight: bold;', width: 200, align: 'center'
                },{field: 'payee_only_text', title: '分配人', width: 220, align: 'center'
                },{field: 'assignment_only_text', title: '收费归属', width: 100, align: 'center'
                },{field: 'rate_only', title: '比率', width: 100, align: 'center'
                },{field: 'rate_only_money', title: '所分金额(元)',style:'color:#01AAED;font-weight: bold;', width: 200, align: 'center'
                },{field: 'amount_already_only', title: '付款金额(元)',style:'color:#FF5722;font-weight: bold;', width: 200, align: 'center'
                },{field: 'update_time', title: '生成时间', width: 200, align: 'center'
                }
            ]]
            , height: 'full-180'
            , page: true
            , title: '个人业绩分配表'
            , limits: [10,20,30,40,50,60,70,80,90,10000000]
            , done: function () {
                layer.close(loading);
            }
        });  //个人业绩统计报表
        //日期
        laydate.render({
            elem: '#range_date_three',
            range: true
            ,trigger: 'click'
        });
        //搜索项
        $('#search_three').click(function () {
            var field = {};
            field.payee_only_text = $('select[name=adjustment_name]').val();
            var create_date_rang = $('input[name=date_range_three]').val();
            if(create_date_rang.length > 0){
                strs_date=create_date_rang.split("-"); //字符分割
                field.start_date = strs_date[0]+'-'+strs_date[1]+'-'+strs_date[2];
                field.end_date = strs_date[3]+'-'+strs_date[4]+'-'+strs_date[5];
            }
            console.log(field);
            tableIns_three.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });

            $.ajax({
                url: '/admin/finance/searchdata?type=' + 3,
                method: "post",
                data: field,
                beforeSend: function () {
                    isLoad = layer.load(0, {
                        shade: false
                    }); //0代表加载的风格，支持0-2
                },
                success: function (result) {
                    //      layer.msg(result.msg);
                    if (result.code === 1) {

                        var only_json_data = eval('(' + result.data + ')');
                        console.log(only_json_data.only_json);
                        $('.label_three').text(only_json_data.only_sum+' 元');

                        var dom_three = document.getElementById("container_three");
                        var myChart_three = echarts.init(dom_three);
                        var app = {};
                        option = null;
                        var data_only = only_json_data.only_json;
                        var only_data =[];
                        var only_name = [];
                        for(var i=0; i < data_only.length; i++){
                            var row = {};
                            row['value'] = data_only[i].value;
                            row['name'] = data_only[i].only_name;
                            only_name[i] = data_only[i].only_name;
                            only_data[i] = row;
                        }

                        option = {
                            title: {
                                left: 'center',
                                top: 20,
                                textStyle: {
                                    color: '#000'
                                }
                            },

                            tooltip : {
                                trigger: 'item',
                                formatter: "{a} <br/>{b} : {c} ({d}%)"
                            },
                            legend: {
                                type: 'scroll',
                                orient: 'vertical',
                                right: 10,
                                top: 20,
                                bottom: 20,
                                data:only_name

                            },
                            series : [
                                {
                                    name: '分配人',
                                    type: 'pie',
                                    radius : '55%',
                                    center: ['50%', '50%'],
                                    data:only_data.sort(function (a, b) { return a.value - b.value; }),

                                    roseType: 'radius',
                                    label: {
                                        normal: {
                                            textStyle: {
                                                fontSize: 16
                                            }
                                        }
                                    },

                                    labelLine: {
                                        normal: {
                                            smooth: 0.2,
                                            length: 10,
                                            length2: 20
                                        }
                                    },



                                    itemStyle: {
                                        normal: {
                                            shadowBlur: 200,
                                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                                        }
                                    },

                                    animationType: 'scale',
                                    animationEasing: 'elasticOut',
                                    animationDelay: function (idx) {
                                        return Math.random() * 200;
                                    }
                                }
                            ]
                        };


                        if (option && typeof option === "object") {
                            myChart_three.setOption(option, true);
                        }


                    }

                },
                complete: function () {
                    layer.close(isLoad)
                },
                error: function (error) {
                    console.log(error)
                }
            });

        });//清除
        $('#clear_three').click(function () {
            $('.layui-form-pane').find('.layui-input-inline').each(function (index, element) {
                $(element).find('input[type=text]').val('');
                $(element).find('select').val('');
            })
            tableIns_three.reload({
                where: {
                    'payee_only_text': '',
                    'start_date': '',
                    'end_date': '',
                    'date_range_three':'',
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            $('.label_three').text('{$only_money_sum}'+' 元');
            var dom_three = document.getElementById("container_three");
            var myChart_three = echarts.init(dom_three);
            var app = {};
            option = null;
            var data_only = eval('{$data_only}');
            var only_data =[];
            var only_name = [];
            for(var i=0; i < data_only.length; i++){
                var row = {};
                row['value'] = data_only[i].value;
                row['name'] = data_only[i].only_name;
                only_name[i] = data_only[i].only_name;
                only_data[i] = row;
            }

            option = {
                title: {
                    left: 'center',
                    top: 20,
                    textStyle: {
                        color: '#000'
                    }
                },

                tooltip : {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    type: 'scroll',
                    orient: 'vertical',
                    right: 10,
                    top: 20,
                    bottom: 20,
                    data:only_name
                },
                series : [
                    {
                        name: '分配人',
                        type: 'pie',
                        radius : '55%',
                        center: ['50%', '50%'],

                        data:only_data.sort(function (a, b) { return a.value - b.value; }),

                        roseType: 'radius',
                        label: {
                            normal: {
                                textStyle: {
                                    fontSize: 16
                                }
                            }
                        },

                        labelLine: {
                            normal: {
                                smooth: 0.2,
                                length: 10,
                                length2: 20
                            }
                        },



                        itemStyle: {
                            normal: {
                                shadowBlur: 200,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        },

                        animationType: 'scale',
                        animationEasing: 'elasticOut',
                        animationDelay: function (idx) {
                            return Math.random() * 200;
                        }
                    }
                ]
            };


            if (option && typeof option === "object") {
                myChart_three.setOption(option, true);
            }
        });


        //数据表格 方法级渲染  统计报表
        var tableIns_four = table.render({
            elem: '#LAY_table_user_four'
            , url: '{:url("finance/refundlist")}?status=' + true
            , method: 'POST'
            , toolbar: 'true' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
            , defaultToolbar: ['print', 'exports'] // 筛选图标
            , loading: true
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code === 1) {
                    res.code = 0;
                } else {
                    res.code = -1;
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data //解析数据列表
                };
            },
            cols: [[
                {field: 'receipt_number', title: '退款凭证', style:'color:#01AAED;font-weight: bold;', width: 200, sort: true, fixed: false, align: 'center'
                }, {field: 'contract_number', title: '订单编号', width: 200, sort: true, fixed: false, align: 'center'
                }, {field: 'campus_name', title: '退款校区', width: 120, align: 'center'
                }, {field: 'student_name', title: '学员姓名', width: 100, align: 'center'
                }, {field: 'total_amount', title: '订单总额(元)', width: 120, align: 'center'
                }, {field: 'amount', title: '已收金额(元)', width: 120, align: 'center'
                }, {field: 'balance', title: '账户余额(元)', width: 120, align: 'center'
                }, {field: 'refund_amount', title: '退款金额(元)',style:'color:#FF5722;font-weight: bold;',  width: 120, align: 'center'
                }, {field: 'experienced_person', title: '经手人', width: 100, align: 'center'
                }, {field: 'refund_channel_text', title: '退款通道', width: 100, align: 'center'
                },{field: 'update_time', title: '退款时间', width: 200, align: 'center',edit: 'text'
                }
            ]]
            , height: 'full-180'
            , page: true
            , title: '退费统计报表'
            , limits: [10,20,30,40,50,60,70,80,90,10000000]
            , done: function () {
                layer.close(loading);
            }
        });  //退费统计报表
        //日期
        laydate.render({
            elem: '#range_date_four',
            range: true
            ,trigger: 'click'
        });
        //搜索项
        $('#search_four').click(function () {
            var field = {};
            field.campus_name = $('select[name=campus_name_refund]').val();
            var create_date_rang = $('input[name=date_range_four]').val();
            if(create_date_rang.length > 0){
                strs_date=create_date_rang.split("-"); //字符分割
                field.start_date = strs_date[0]+'-'+strs_date[1]+'-'+strs_date[2];
                field.end_date = strs_date[3]+'-'+strs_date[4]+'-'+strs_date[5];
            }
            console.log(field);
            tableIns_four.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });

            $.ajax({
                url: '/admin/finance/searchdata?type=' + 4,
                method: "post",
                data: field,
                beforeSend: function () {
                    isLoad = layer.load(0, {
                        shade: false
                    }); //0代表加载的风格，支持0-2
                },
                success: function (result) {
                    //      layer.msg(result.msg);
                    if (result.code === 1) {

                        var campus_refund_json__data = eval('(' + result.data + ')');
                        console.log(campus_refund_json__data.campus_refund_json);
                        $('.label_four').text(campus_refund_json__data.campus_refund_sum+' 元');

                        var dom_four = document.getElementById("container_four");
                        var myChart_four = echarts.init(dom_four);
                        var app = {};
                        option = null;

                        var data_refund_campus = campus_refund_json__data.campus_refund_json;
                        var campus_refund_data =[];
                        var campus_refund_name = [];
                        for(var i=0; i < data_refund_campus.length; i++){
                            var row = {};
                            campus_refund_data[i] = data_refund_campus[i].refund_value;
                            campus_refund_name[i] = data_refund_campus[i].refund_campus_name;
                        }


                        option = {
                            title: {

                                left: 'center',
                                top: 20,
                                textStyle: {
                                    color: '#000'
                                }
                            },
                            color: ['#3398DB'],
                            tooltip : {
                                trigger: 'axis',
                                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                                }
                            },
                            legend: {
                                right: 10,


                                data:['退费金额']

                            },

                            xAxis: {
                                type: 'category',
                                data: campus_refund_name,
                                axisTick: {
                                    alignWithLabel: true
                                }
                            },
                            yAxis: {
                                type: 'value'
                            },

                            series : [
                                {
                                    name: '退费金额',
                                    type: 'bar',
                                    barWidth: '40%',
                                    radius : '55%',
                                    center: ['50%', '50%'],

                                    data:campus_refund_data.sort(function (a, b) { return a.value - b.value; }),

                                    roseType: 'radius',
                                    label: {
                                        normal: {
                                            textStyle: {

                                                fontSize: 16
                                            }
                                        }
                                    },

                                    labelLine: {
                                        normal: {

                                            smooth: 0.2,
                                            length: 10,
                                            length2: 20
                                        }
                                    },



                                    itemStyle: {
                                        normal: {

                                            shadowBlur: 200,
                                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                                        }
                                    },

                                    animationType: 'scale',
                                    animationEasing: 'elasticOut',
                                    animationDelay: function (idx) {
                                        return Math.random() * 200;
                                    }
                                }
                            ]
                        };


                        if (option && typeof option === "object") {
                            myChart_four.setOption(option, true);
                        }


                    }

                },
                complete: function () {
                    layer.close(isLoad)
                },
                error: function (error) {
                    console.log(error)
                }
            });

        });//清除
        $('#clear_four').click(function () {
            $('.layui-form-pane').find('.layui-input-inline').each(function (index, element) {
                $(element).find('input[type=text]').val('');
                $(element).find('select').val('');
            })
            tableIns_four.reload({
                where: {
                    'campus_name_refund': '',
                    'start_date': '',
                    'end_date': '',
                    'date_range_four':'',
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            $('.label_four').text('{$campus_refund_money_sum}'+' 元');

            var dom_four = document.getElementById("container_four");
            var myChart_four = echarts.init(dom_four);
            var app = {};
            option = null;


            var data_refund_campus = eval('{$data_refund_campus}');
            var campus_refund_data =[];
            var campus_refund_name = [];
            for(var i=0; i < data_refund_campus.length; i++){
                var row = {};
                campus_refund_data[i] = data_refund_campus[i].refund_value;
                campus_refund_name[i] = data_refund_campus[i].refund_campus_name;
            }


            option = {
                title: {
                    //    text: '个人统计报表',
                    left: 'center',
                    top: 20,
                    textStyle: {
                        color: '#000'
                    }
                },
                color: ['#3398DB'],
                tooltip : {
                    trigger: 'axis',
                    axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                        type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    }
                },
                legend: {
                    right: 10,


                    data:['退费金额']

                    //  selected: {'未分配':true, '未处理':true,'已联系':true,'已邀约':true,'已上门':false,'已交定金':false,'已成交':false}
                },

                xAxis: {
                    type: 'category',
                    data: campus_refund_name,
                    axisTick: {
                        alignWithLabel: true
                    }
                },
                yAxis: {
                    type: 'value'
                },

                series : [
                    {
                        name: '退费金额',
                        type: 'bar',
                        barWidth: '40%',
                        radius : '55%',
                        center: ['50%', '50%'],

                        data:campus_refund_data.sort(function (a, b) { return a.value - b.value; }),

                        roseType: 'radius',
                        label: {
                            normal: {
                                textStyle: {
                                    //         color: 'rgba(0, 191, 255, 1)',
                                    fontSize: 16
                                }
                            }
                        },

                        labelLine: {
                            normal: {
                                /*
                                 lineStyle: {
                                 color: 'rgba(0, 191, 255, 1)'
                                 },
                                 */
                                smooth: 0.2,
                                length: 10,
                                length2: 20
                            }
                        },



                        itemStyle: {
                            normal: {
                                //                 color: '#c23531',
                                shadowBlur: 200,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        },

                        animationType: 'scale',
                        animationEasing: 'elasticOut',
                        animationDelay: function (idx) {
                            return Math.random() * 200;
                        }
                    }
                ]
            };


            if (option && typeof option === "object") {
                myChart_four.setOption(option, true);
            }

        });



    });
</script>

